<?php defined('SYSPATH') OR die('No Direct Script Access');

Class Controller_Register extends Controller_PublicTemplate {
	
	public function action_index()
	{
		$this->template->title = 'Registratie';
		$view = new View('pages/register');
		
		if(isset($_POST['submit'])) 
		{ 
			//Validation
			if(Helper_Validation::validate_registration($_POST['name'], $_POST['password1'], $_POST['password2'])) 
			{ 	
				$user = new Model_User();
				$user->insert_user($_POST['name'], $_POST['password1']);
				$message = 'Registratie gelukt, u kunt nu inloggen.';
			} 
			else 
			{ 
				$message = 'Onjuiste gegevens, probeer het opnieuw.';
			}
		}
		
		$view->bind("message", $message);
		$this->template->content = $view;
	}
}